#ifndef __IP_ADDR_H__
#define __IP_ADDR_H__
#include "stm32f4xx.h"

#ifdef __cplusplus
extern "C" {
#endif
 
/** 0.0.0.0 */
#define IPADDR_ANY          ((uint32_t)0x00000000UL)
/** 255.255.255.255 */
#define IPADDR_BROADCAST    ((uint32_t)0xffffffffUL)
/**2.255.255.255*/  
#define AerNet_BROADCAST    ((uint32_t)0x02ffffffUL)
  
#define AerNet_BROADCAST1    ((uint32_t)0x10ffffffUL) 
/**只关注后八位是否为广播**/
#define  IP4DDR_BROADCAST     ((uint32_t)0x0000FFFFUL)

#define ip_addr_broadcast(addr1) (addr1)->addr&IP4DDR_BROADCAST\
                                        ==IP4DDR_BROADCAST

#define ip_addr_cmp(addr1, addr2) ((addr1)->addr == (addr2)->addr)

#define ip_addr_set(dest, src) ((dest)->addr = \
                                    ((src) == NULL ? 0 : \
                                    (src)->addr))  
#define IP4_ADDR(ipaddr, a,b,c,d) \
        (ipaddr)->addr = ((uint32_t)((a) & 0xff) << 24) | \
                         ((uint32_t)((b) & 0xff) << 16) | \
                         ((uint32_t)((c) & 0xff) << 8)  | \
                          (uint32_t)((d) & 0xff)

#define ADDR_IP4(ipaddr, a,b,c,d) \
                          a=ipaddr.addr>>24;\
                          b=ipaddr.addr>>16;\
                          c=ipaddr.addr>>8;\
                          d=ipaddr.addr;
typedef struct{
  uint32_t addr;
}ip_addr_t; 
#endif
